﻿//    Miracinera - an adventure game (player).
//    Copyright (C) [2010]  [Christian Syska]
//
//    This file is part of Miracinera.
//
//    Miracinera is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Miracinera is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Miracinera.  If not, see <http://www.gnu.org/licenses/>.
//
//    Further information on the Miracinera project can be found on http://code.google.com/p/miracinera/
//    If there are any questions, you can contact me via email: Belua85@gmail.com

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Miracinera.Globals;

namespace Miracinera.Classes.Map
{
    /// <summary>
    /// Interaktionslogik für Minimap.xaml
    /// </summary>
    public partial class Minimap : UserControl
    {
        public Minimap()
        {
            InitializeComponent();
        }

        /// <summary>
        /// A method for building the Minimap with a given width and height
        /// </summary>
        /// <param name="x">Width of the map (i.e. number of columns</param>
        /// <param name="y">Height of the map (i.e. number of rows)</param>
        public void BuildMap(int x, int y)
        {
            //Add columns
            for (int i = 0; (i < x)||(i < y); i++)
            {
                ColumnDefinition cd = new ColumnDefinition();
                cd.Name = "" + i;
                this.MapGrid.ColumnDefinitions.Add(cd);
            }

            //Add rows
            for (int i = 0; i < y; i++)
            {
                RowDefinition rd = new RowDefinition();
                rd.Name = "" + i;
                this.MapGrid.RowDefinitions.Add(rd);
            }

            //Create a UserControl for each cell in the grid
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    UserControl uc = new UserControl();
                    uc.Name = "MapSquare_" + i + "x" + j;
                    Grid.SetColumn(uc, i);
                    Grid.SetRow(uc, j);
                    this.MapGrid.Children.Add(uc);
                }
            }
        }


        public void IncRoom(Room room, int x, int y)
        {
            if (x > this.MapGrid.ColumnDefinitions.Count) System.Windows.Forms.MessageBox.Show(ERR.IncRoomWidthHeightError);
        }
    }
}
